<div class="nav_item fl"> <span class="nav_item_i"><em>王艳萍服务项目</em></span> 
        <!-- 左边导航 -->
        <div class="item_menu">
          <ul class="fl">
          {foreach $type as $data}
            <li>
              <div class="item_menu_left fl">
                <h3><a href="#"><i class="{$data['ico']}"></i><em>{$data['name']}</em><b></b></a></h3>
              </div>
            </li>
          {/foreach}
          </ul>
          <div class="item_menu_div fl"> 
            <!-- 眼部塑美 -->
            {foreach $type as $data}
            <div class="item_menu_con">
              <div class="item_menu_l ">  
             <!-- 眼部美容-->
                {foreach $data['child'] as $data2}
                <div class="item_menu_son">
                  <h3><a href="#" title="眼部美容">{$data2['name']}</a></h3>
                  <div class="item_menu_son_div">
                    <ul>
                      {foreach $data2['child2'] as $data3}
                      <li><a href="#" target="_blank">{$data3['name']}{$data3['status']==1?'<i></i>':''}</a></li>
                      {/foreach}
                    </ul>             
                  </div>
                  <div class="both"></div>
                </div>
                {/foreach}
                <div  class="item_menu_son">            
                   <img src="__STATIC__/images/item_menu_son_img.jpg" alt="">
                </div>
              </div>
            </div>
          {/foreach}
          </div>
        </div>
        <!-- 左边导航结束 --> 
      </div>
	  
<?php
header("Content-type:text/html;charset=utf-8");
$type = $this->types();
$this->assign('type',$type);

	public function types()
    {
        $options = [
            'type'  =>  'Redis', // 缓存类型为File
            'expire'=>  7200, // 缓存有效期为永久有效
            'prefix'=>  '',//缓存的前缀
          
        ];
        $redis=Cache::connect($options);

        if(!$redis->get('types')){
            //获取一级分类
            $type = Db::table('type')->where(array('pid'=>0))->select();
            $type2 = array();
            $type3 = array();
            foreach($type as $key=>$value){
                $type[$key]['child']=array();//二级分类的名字
                $type2=Db::table('type')->where("pid=".$value['id'])->select();//获取二级分类

                foreach($type2 as $k=>$v){
                    
                  

                    array_push($type[$key]['child'],$v);//合并一级与二级分类
                    $type[$key]['child'][$k]['child2']=array();////三级分类的名字
                   
                        $type3=Db::table('type')->where("pid=".$v['id'])->select();//获取三级分类
                        foreach($type3 as $v2){


                              array_push($type[$key]['child'][$k]['child2'],$v2);//合并一级二级三级分类
                        }
                      
                   
                }

            }
            $redis->set('types',$type);
            return $type;
        }else{
            return $redis->get('types');
        }
    }
?>